www.gusucode.com > PHPBB轻型PHP论坛 含中文语言包 3.1.2PHP源码程序 > PHPBB轻型PHP论坛 含中文语言包 3.1.2/mandarin_chinese_(simplified_script)_1_0_4/phpBB3/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\DataCollector; /** * DataCollector. * * Children of this class must store the collected data in the data property. * * @author Fabien Potencier <fabien@symfony.com> */ abstract class DataCollector implements DataCollectorInterface, \Serializable { protected $data; public function serialize() { return serialize($this->data); } public function unserialize($data) { $this->data = unserialize($data); } /** * Converts a PHP variable to a string. * * @param mixed $var A PHP variable * * @return string The string representation of the variable */ protected function varToString($var) { if (is_object($var)) { return sprintf('Object(%s)', get_class($var)); } if (is_array($var)) { $a = array(); foreach ($var as $k => $v) { $a[] = sprintf('%s => %s', $k, $this->varToString($v)); } return sprintf("Array(%s)", implode(', ', $a)); } if (is_resource($var)) { return sprintf('Resource(%s#%d)', get_resource_type($var), $var); } if (null === $var) { return 'null'; } if (false === $var) { return 'false'; } if (true === $var) { return 'true'; } return (string) $var; } }